package com.example.mrzhou.srtfoodapplication;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.List;

/**
 * Created by Mr.Zhou on 2017/1/23.
 */

public class FlavorAdapter extends ArrayAdapter<Flavor> {

    //flavor类的列表适配器

    private int resourceId;

    public FlavorAdapter(Context context, int textViewResourceId, List<Flavor> objects) {
        super(context, textViewResourceId, objects);
        resourceId = textViewResourceId;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent){
        Flavor flavor=getItem(position);
        View view = LayoutInflater.from(getContext()).inflate(resourceId,null);
        TextView flavorName = (TextView) view.findViewById(R.id.flavor_name);
        flavorName.setText(flavor.getName());
        return view;
    }

}
